﻿using Application.Models;
using Application.Roles.Commands.RoleWrite;
using Application.Roles.Commands.UpdatePermissions;
using Application.Roles.Interfaces.Repositories;
using Domain.Roles.Entities;
using Domain.Roles.ValueObjects;
using Infrastructure.Data.Contexts;

namespace Infrastructure.Repositories
{
    public class RoleWriteRepository(AppDbContext context) : IRoleWriteRepository
    {
        public async Task<Guid> AddAsync(RoleWriteCommand cmd, CancellationToken cancellationToken = default)
        {
            context.Database.EnsureCreated();
            var role = Role.Create(RoleName.Create(cmd.Name),
                cmd.PermissionSigns,
                cmd.Enable,
                cmd.Description
                );
            context.Roles.Add(role);
            await context.SaveChangesAsync(cancellationToken);
            return role.Id;
        }

        public Task<IList<RoleDto>> UpdateAsync(RoleUpdaeCommand roles, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }
    }
}
